<?php
class Cerad_Action
{
	protected $context   = NULL;
	protected $requestx  = NULL;
	protected $responsex = NULL;
	
	protected $dbx = NULL;
		
	function __construct($context)
	{
		$this->context = $context;
	}
	function process()
	{
		$request  = $this->getRequest();
		$response = $this->getResponse();
		
		if ($request->isQuery()) $this->processQuery();
		if ($request->isPost())  $this->processPost();
		
		echo $response;	
	}
	function processQuery()
	{
		echo "<h2>Cerad_Action process query</h2>";
	}
	function processPost()
	{
		echo "<h2>Cerad_Action process post</h2>";
	}
	function getRequest()
	{
		if (!$this->requestx) 
		{
			$this->requestx = $this->context->getRequest();
		}
		return $this->requestx;
	}
	function getResponse()
	{
		if (!$this->responsex) 
		{
			$this->responsex = $this->context->getResponse();
		}
		return $this->responsex;
	}
	function getDb()
	{
		if (!$this->dbx) 
		{
			$this->dbx = $this->context->getDb();
		}
		return $this->dbx;
	}
	function getContext() { return $this->context; }
	function getSession() { return $this->context->getSession(); }
	
	public function link($action = NULL,$data = NULL)
    {
        return $this->context->getUrl()->link($action,$data);
    }
}
?>